<?php
class AdminController extends Controller{
	//载入修改当前用户的表单
	public function indexAction(){
		$nav=$this->getNavs();
		$libraryinfo=$this->getFooter();
		$title="更改密码";
		$username=$_SESSION['admin_name'];
		$include_file="changeadm";
		include_once VIEWS_PATH."index.html";
	
	}
	
	//修改数据
	public function updateAction(){
		
		$data['name']=$_POST['name'];
		
		$oldpwd=$_POST['oldpwd'];
		$data['pwd']=$_POST['newpwd'];
		$newpwd1=$_POST['newpwd1'];
		if ($data['name']!=$_SESSION['admin_name']) {
			$this->jump("index.php?c=admin&a=index", "用户名非法!");
		}
		if ($data['pwd']!=$newpwd1) {
			$this->jump("index.php?c=admin&a=index", "两次输入的密码不一致!");
		}
		$this->helper("input");
		$data=deepspecialchars($data);
		$adminmodel=new AdminModel("tb_manager");
		$where="name='{$data['name']}' and pwd='{$oldpwd}'";
		if ($adminmodel->total($where)!=1) {
			$this->jump("index.php?c=admin&a=index", "密码验证错误!");
		}
		
		if ($adminmodel->changePwd($data)) {
			
			$this->jump("index.php?c=login&a=login", "修改成功!,请重新登录!");
			session_destroy();
		}else {
			$this->jump("index.php?c=admin&a=index", "密码修改失败!");
		}
	}
	
	
	
	
}